<?php

namespace app\api\controller;

use app\api\BaseController;
use app\api\logic\AuthLogic;
use app\api\logic\Jwt;
use app\api\logic\UserLogic;
use app\api\model\UserModel;
use think\facade\Log;


class Auth extends BaseController
{

    // 免登录
    public function Login()
    {
        $params = $this->request->param();

        $userLogic = new UserLogic();

        $userInfo = $userLogic->userInfo($params['authCode']);
        Log::write($userInfo,'myLog');
        $userModel = UserModel::where('user_id_ding',$userInfo['result']['userid'])
            ->field('id,name,department_id')
            ->find()->toArray();

        $jwt = new Jwt();

        $token = $jwt->encrypt($userModel);


        return json($token);

    }

    public function userDetails()
    {
        $authLogic = new AuthLogic();

        $res = $authLogic->userDetails('1633321269760535');

        return json($res);
    }
}